﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace GWModflow.FileLayers
{
    public  class PStronglyImplicitProcedure:Package
    {
        public PStronglyImplicitProcedure()
        {
            this._fileType = FileType.SIP;
            this.Fname = "solution.sip";

            this.Nunit = 33;
        }


        int _MAXITER;

        /// <summary>
        /// 为尝试解决有限差分方程在一个时间步长最大的迭代次数
        /// </summary>
        public int MAXITER
        {
            get { return _MAXITER; }
            set { _MAXITER = value; }
        }

        int _NPARM;

        /// <summary>
        /// 迭代变量使用的数量，5个一般就足够了
        /// </summary>
        public int NPARM
        {
            get { return _NPARM; }
            set { _NPARM = value; }
        }

        double _ACCL;

        /// <summary>
        /// 加速变量，一般来说大约0，且一般等于1，如果输入0，那么按1处理。
        /// </summary>
        public double ACCL
        {
            get { return _ACCL; }
            set { _ACCL = value; }
        }

        double _HCLOSE;

        /// <summary>
        /// 水头变化收敛准则，
        /// </summary>
        public double HCLOSE
        {
            get { return _HCLOSE; }
            set { _HCLOSE = value; }
        }

        int _IPCALC;
        /// <summary>
        /// 计算迭代变量的seed的来源,0 为用户输入 1 为内部计算
        /// </summary>
        public int IPCALC
        {
            get { return _IPCALC; }
            set { _IPCALC = value; }
        }

        double _WSEED;

        /// <summary>
        /// 计算迭代变量的seed
        /// </summary>
        public double WSEED
        {
            get { return _WSEED; }
            set { _WSEED = value; }
        }

        int _IPRSIP;

        /// <summary>
        /// Sip的输出间隔。如果等于0，则按999处理。
        /// </summary>
        public int IPRSIP
        {
            get { return _IPRSIP; }
            set { _IPRSIP = value; }
        }



        public override void WriteFile(string path)
        {
            //默认BasicPackage为Free输出
            string content = "# HuanAnKeJi SIP File"+"\r\n";
            //添加#Text

            //添加MXITER NPARM
            content += string.Format("{0,10}", _MAXITER) + string.Format("{0,10}", _NPARM) + "                 MXITER  NPARM\r\n";

            //添加ACCL HCLOSE IPCALC WSEED IPRSIP
            content += _ACCL.ToString("0.00000E+00") + "  " + _HCLOSE.ToString("0.00000E+00") + "  " + string.Format("{0,10}", _IPCALC) + "  "
                + _WSEED.ToString("0.00000E+00") + "  " + string.Format("{0,10}", _IPRSIP) + "    ACCL HCLOSE IPCALC WSEED IPRSIP\r\n";
            string fname = path + Fname;

            FXnaInfrastructure.FileHelper.WriteFile(fname, content);
        }
    }
}
